<?php /*a:1:{s:61:"/www/wwwroot/103.151.217.18/app/admin/view/main/transfer.html";i:1693658665;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户管理</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=318"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    
     <div class="layui-row layui-col-space15" style="margin-bottom: 10px">
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    提现申请金额<span class="layui-badge layui-bg-cyan pull-right">元</span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font"><span style="font-size: 22px">¥</span><span style="font-size: 26px;line-height: 1;" id="foot_num"></span ></span></p>
                </div>
            </div>
        </div>

        <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    已提现金额<span class="layui-badge layui-bg-cyan pull-right">元</span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font"><span style="font-size: 22px">¥</span><span style="font-size: 26px;line-height: 1;" id="success_num"></span ></span></p>
                </div>
            </div>
        </div>
    </div>
    
    <div class="layui-card">
        <div class="layui-card-body">
            <blockquote class="layui-elem-quote layui-quote-nm">注意：提现设置备注将会同步给用户备注</blockquote>

            <!-- 表格工具栏 -->
            <form class="layui-form toolbar">
                <div class="layui-form-item">
                    <!--搜索区域-->
                    <div class="layui-inline">
                        <label class="layui-form-label">搜索信息：</label>
                        <div class="layui-input-inline" style="width: 300px;">
                            <input name="key" class="layui-input" placeholder="输入 卡号"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">类型：</label>
                        <div class="layui-input-inline" style="width: 300px;">
                            <select name="type" lay-verify="required">
                                <option value="all">全部</option>
                                <option value="1">待处理</option>
                                <option value="2">已通过</option>
                                <option value="3">已拒绝</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn" lay-filter="TbSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                    </div>
                    <!--搜索区域结束-->
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="Table" lay-filter="Table"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="TbBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="checkOk">通过</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="checkError">拒绝</a>
    <a class="layui-btn layui-btn-xs" lay-event="remark">备注</a>
</script>
<!-- js部分 -->
<script type="text/html" id="AddEditModel">
    <form id="AddEditForm" lay-filter="AddEditForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <input name="uid" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <input name="remarks" placeholder="备注" class="layui-input"/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="AddEditSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/static/assets/js/common.js?v=318"></script>
<script>
    layui.use(['layer', 'form', 'table', 'util', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;

        /* 渲染表格 */
        var insTb = table.render({
            elem: '#Table',
            url: "<?php echo url('admin/main/transferList'); ?>",
            page: true,
            limit: 20,
            size: 'sm',
            parseData: function (res) {
                $("#success_num").text(res.success_num);
                $("#foot_num").text(res.foot_num);

            },
            toolbar: ['<p>',
                '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
                '<button lay-event="checkSuccess" class="layui-btn layui-btn-sm">通过</button>',
                '<button lay-event="checkErrors" class="layui-btn layui-btn-sm">拒绝</button>',
                '</p>'].join(''),
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox'},
                // 表格字段开始
                {type: 'numbers'},
                {field: 'id', title: 'ID', width: 80},
                {field: 'remarks', title: '备注', width: 80},
                {field: 'username', title: '账号'},
                {field: 'account', title: '支付宝'},
                {field: 'name', title: '姓名', width: 100},
                {field: 'price', title: '提现金额', width: 100},
                {field: 'fee', title: '手续费费率', width: 100},
                {field: 'price_last', title: '实际金额', width: 100},

                {field: 'put_time', title: '申请时间'},
                {
                    field: 'transfer_status', title: '状态', width: 100, templet: function (d) {
                        //状态 0=待审核 1=提现中 2=提现成功 3=提现失败
                        if (d.transfer_status == 1) {
                            return '<span>待处理</span>'
                        }
                        if (d.transfer_status == 2) {
                            return '<span class="text-success">提现成功</span>'
                        }
                        if (d.transfer_status == 3) {
                            return '<span class="text-danger">提现失败</span>'
                        }
                    }
                },
                {field: 'put_time', title: '注册时间'},
                {field: 'count_price', title: '总提现额', width: 100},
                {title: '操作', toolbar: '#TbBar', align: 'center', width: 160}
            ]]
        });

        /* 表格搜索 */
        form.on('submit(TbSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });

        /* 表格工具条点击事件 */
        table.on('tool(Table)', function (obj) {
            if (obj.event === 'checkOk') {
                checkTask(obj,'success')
            }
            if (obj.event === 'checkError') {
                checkTask(obj,'error')
            }
            if(obj.event === 'remark'){
                showEditModel(obj.data)
            }
        });

       /* 表格头工具栏点击事件 */
        table.on('toolbar(Table)', function (obj) {
            if (obj.event === 'del') { // 删除
                var checkRows = table.checkStatus('Table');
                if (checkRows.data.length === 0) {
                    layer.msg('请选择要删除的数据', {icon: 2});
                    return;
                }
                var ids = checkRows.data.map(function (d) {
                    return d.id;
                });
                doDel({ids: ids});
            }

            if (obj.event === 'checkSuccess') {
                var checkRows = table.checkStatus('Table');
                if (checkRows.data.length === 0) {
                    layer.msg('请选择要通过的数据', {icon: 2});
                    return;
                }
                var ids = checkRows.data.map(function (d) {
                    return d.id;
                });
                doCheckSuccess({ids: ids});
            }


            if (obj.event === 'checkErrors') {
                var checkRows = table.checkStatus('Table');
                if (checkRows.data.length === 0) {
                    layer.msg('请选择要拒绝的数据', {icon: 2});
                    return;
                }
                var ids = checkRows.data.map(function (d) {
                    return d.id;
                });
                doCheckErrors({ids: ids});
            }

        });
        function doCheckSuccess(obj) {
            layer.confirm('确定要通过选中数据吗？', {
                skin: 'layui-layer-admin',
                shade: .1,
            }, function (i) {
                layer.close(i);
                var loadIndex = layer.load(2);
                $.get("<?php echo url('admin/main/transferBatchCheck'); ?>", {
                    ids: obj.ids ? obj.ids.join(',') : '',
                    type: 'success'
                }, function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }


        function doCheckErrors(obj) {
            layer.confirm('确定要拒绝选中数据吗？', {
                skin: 'layui-layer-admin',
                shade: .1,
            }, function (i) {
                layer.close(i);
                var loadIndex = layer.load(2);
                $.get("<?php echo url('admin/main/transferBatchCheck'); ?>", {
                    ids: obj.ids ? obj.ids.join(',') : '',
                    type: 'error'
                }, function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }

        function checkTask(obj,type){
            $.get("<?php echo url('admin/main/transferCheck'); ?>", {
                id:obj.data.id,
                type:type
            }, function (res) {
                if (res.code === 200) {
                    layer.msg(res.msg, {icon: 1});
                    insTb.reload({page: {curr: 1}});
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');
        }
        /* 删除 */
        function doDel(obj) {
            layer.confirm('确定要删除选中数据吗？', {
                skin: 'layui-layer-admin',
                shade: .1,
            }, function (i) {
                layer.close(i);
                var loadIndex = layer.load(2);
                $.get("<?php echo url('admin/main/transferDel'); ?>", {
                    id: obj.data ? obj.data.id : '',
                    ids: obj.ids ? obj.ids.join(',') : ''
                }, function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload({page: {curr: 1}});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }

        function showEditModel(mData) {
            admin.open({
                type: 1,
                title: '修改备注',
                content: $('#AddEditModel').html(),
                // area: '500px',
                offset: 'auto',
                success: function (layero, dIndex) {
                    // 回显表单数据
                    form.val('AddEditForm', mData);
                    // 表单提交事件
                    form.on('submit(AddEditSubmit)', function (data) {
                        var loadIndex = layer.load(2);
                        let url = "<?php echo url('admin/main/transferRemark'); ?>";
                        $.post(url, data.field, function (res) {
                            layer.close(loadIndex);
                            if (res.code === 200) {
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload({page: {curr: 1}});
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
                        return false;
                    });
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                }
            });
        }
    });
</script>
</body>
</html>
